<?php

    class ImageMerger
    {
        public function mergeImageOnBackground( $color, $image, $return = false )
        {
            $im = imagecreatefrompng( $image );
            
            $size = getImageSize( $image );
            $bg = imagecreatetruecolor( $size[0], $size[1] );

            imagealphablending( $bg, true );
            imagealphablending( $im, true );
            
            
            
            $bgcolor = imagecolorallocate( $bg, $color['red'], $color['green'], $color['blue'] );

            imagefill( $bg, 0, 0, $bgcolor );
            imagecopy( $bg, $im, 0, 0, 0, 0, $size[0], $size[1] );

            if ( $return === false )
                imagepng( $bg );
            else
                return $bg;
        }
    }


?>